package com.spring.service.impl;

import com.spring.entity.Company;
import com.spring.entity.Position;
import com.spring.mapper.CompanyMapper;
import com.spring.mapper.PositionMapper;
import com.spring.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("positionService")
@Transactional
public class PositionServiceImpl implements PositionService {

    @Autowired
    private PositionMapper positionMapper;
    @Autowired
    private CompanyMapper companyMapper;


    @Override
    public void updatePhoto(Company company) {
        this.companyMapper.updatePhoto(company);
    }

    @Override
    public void addCompany(Company company) {
        this.companyMapper.save(company);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Position> find(String pname, Double minSal, Double maxSal) {
        return this.positionMapper.find(pname,minSal,maxSal);
    }

    @Override
    @Transactional(readOnly = true)
    public Position findById(Integer pid) {
        return this.positionMapper.findById(pid);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Company> findAllComp() {
        return this.companyMapper.findAll();
    }

    @Override
    public void add(Position position) {
        this.positionMapper.save(position);
    }

    @Override
    public void replace(Position position) {
        this.positionMapper.update(position);
    }

    @Override
    public void remove(Integer pid) {
        this.positionMapper.delete(pid);
    }
}
